package com.ruoyi.web.controller.miniapp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MiniBanner;
import com.ruoyi.system.service.IMiniBannerService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * banner轮播图列Controller
 * 
 * @author duantao
 * @date 2025-09-11
 */
@RestController
@RequestMapping("/miniapp/banner")
public class MiniBannerController extends BaseController
{
    @Autowired
    private IMiniBannerService miniBannerService;

    /**
     * 查询banner轮播图列列表
     */
//    @PreAuthorize("@ss.hasPermi('miniapp:banner:list')")
    @GetMapping("/list")
    public TableDataInfo list(MiniBanner miniBanner)
    {
        startPage();
        List<MiniBanner> list = miniBannerService.selectMiniBannerList(miniBanner);
        return getDataTable(list);
    }

    /**
     * 导出banner轮播图列列表
     */
    @PreAuthorize("@ss.hasPermi('miniapp:banner:export')")
    @Log(title = "banner轮播图列", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MiniBanner miniBanner)
    {
        List<MiniBanner> list = miniBannerService.selectMiniBannerList(miniBanner);
        ExcelUtil<MiniBanner> util = new ExcelUtil<MiniBanner>(MiniBanner.class);
        util.exportExcel(response, list, "banner轮播图列数据");
    }

    /**
     * 获取banner轮播图列详细信息
     */
//    @PreAuthorize("@ss.hasPermi('miniapp:banner:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(miniBannerService.selectMiniBannerById(id));
    }

    /**
     * 新增banner轮播图列
     */
    @PreAuthorize("@ss.hasPermi('miniapp:banner:add')")
    @Log(title = "banner轮播图列", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MiniBanner miniBanner)
    {
        return toAjax(miniBannerService.insertMiniBanner(miniBanner));
    }

    /**
     * 修改banner轮播图列
     */
    @PreAuthorize("@ss.hasPermi('miniapp:banner:edit')")
    @Log(title = "banner轮播图列", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MiniBanner miniBanner)
    {
        return toAjax(miniBannerService.updateMiniBanner(miniBanner));
    }

    /**
     * 删除banner轮播图列
     */
    @PreAuthorize("@ss.hasPermi('miniapp:banner:remove')")
    @Log(title = "banner轮播图列", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(miniBannerService.deleteMiniBannerByIds(ids));
    }
}
